package com.situ.mall.admin.controller;


import com.situ.mall.admin.entity.Menu;
import com.situ.mall.admin.service.IMenuService;
import com.situ.mall.admin.vo.LayuiTableVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author membergpf
 * @since 2023-03-18
 */
@Controller
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    IMenuService menuService;


    @RequestMapping("/index")
    public String index(){

        return "menu";
    }

    @GetMapping("/list")
    @ResponseBody
    public LayuiTableVO list(){
        return menuService.doList();
    }

    @PostMapping("/del")
    @ResponseBody
    public void doDelete(Integer id){
        menuService.doDelete(id);
    }

    @GetMapping("/{id}")
    @ResponseBody
    public Menu selectById(@PathVariable("id") Integer id){
        return menuService.getById(id);
    }

    @PostMapping("/save")
    @ResponseBody
    public void save(Menu menu){
        menuService.saveOrUpdate(menu);
    }

}
